layui.use(['form', 'element', 'util', 'carousel', 'laypage', 'layer','table'], function () {
    var table = layui.table;
    table.render({
        elem: '#order_detail'
        , url: basePath + '/orderdata/' + orderid
        , page: {
            layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
            , groups: 3
            , limits: [20, 50, 100]
            , limit: 20
            , totalRow: true    //开启合计行
        }, cols: [[
            {field: 'commid', title: '商品编号', width: 200, align: 'center'}
            , {field: 'commname', title: '名称', width: 150, align: 'center'}
            , {field: 'commdesc', title: '描述', width: 300, align: 'center'}
            , {field: 'thinkmoney', title: '价格（RMB）', width: 150, align: 'center', sort: true}
            , {field: 'category', title: '农场', width: 150, align: 'center'}
            , {field: 'number', title: '数量', width: 80, align: 'center', sort: true}
            , {title: '操作', toolbar: '#barDemo', width:100, align:'center'}
        ]]
        , width: 1130
        , height: 500
    });
    table.on('tool(test_order_detail)', function (obj) {
        var data = obj.data;
        if (obj.event === 'xiangqing') {
            $.ajax({
                url: basePath+'/product-detail-isnull/'+data.commid,
                data: "",
                contentType: "application/json;charset=UTF-8", //发送数据的格式
                type: "get",
                dataType: "json", //回调
                beforeSend: function () {
                    layer.load(1, { //icon支持传入0-2
                        content: '请稍等...',
                        success: function (layero) {
                            layero.find('.layui-layer-content').css({
                                'padding-top': '39px',
                                'width': '60px'
                            });
                        }
                    });
                },
                complete: function () {
                    layer.closeAll('loading');
                },
                success: function (shuju) {
                    console.log(shuju)
                    if(shuju.status===200){
                        window.open(basePath+"/product-detail/"+data.commid)
                    }else {
                        layer.msg(shuju.message, {
                            time: 1000,
                            icon: 2,
                            offset: '50px'
                        });
                    }
                }
            });
        }
    });
});